package com.link.auth.util;

import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * @author gsan
 * @create 2019/3/29
 */

@Component
public class TrueOrFalse {

    @Resource
    private Environment env;

    public boolean isCluster() {
        //获取redis集群开关的状态
        final String redisClusterDtateKey = "spring.redis.cluster.state";
        String redisClusterStateRaw = env.getProperty(redisClusterDtateKey);
        if (StringUtils.isEmpty(redisClusterStateRaw)) {
            return false;
        }
        return Boolean.parseBoolean(redisClusterStateRaw);
    }
}
